package com.cloud.school.bus.teacherhelper.modules.notice;

import java.util.Collections;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ListView;

import com.cloud.school.bus.teacherhelper.R;
import com.cloud.school.bus.teacherhelper.base.activity.BaseActivity;
import com.cloud.school.bus.teacherhelper.base.view.TitleNavBarView;
import com.cloud.school.bus.teacherhelper.entitys.Notice;
import com.cloud.school.bus.teacherhelper.modules.SlidingActivity;
import com.cloud.school.bus.teacherhelper.modules.notice.adapter.NoticeDetailAdapter;
/**
 * 通知详情
 * @author jiahongfei
 *
 */
public class NoticeDetailActivity extends BaseActivity {
	
	private ListView mListView;
	private NoticeDetailAdapter mNoticeDetailAdapter;
	private View mNoticeDetailStatusView;
	
	private Notice mNotice;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_notice_detail);

		init();
	}
	
	@Override
	protected void init() {
		
		mNotice = (Notice) getIntent().getSerializableExtra("Notice");
		
		mNoticeDetailStatusView = findViewById(R.id.noticeDetailStatusView);
		mListView = (ListView)findViewById(R.id.listView);
		mNoticeDetailAdapter = new NoticeDetailAdapter(mContext, mNotice);
		mListView.setAdapter(mNoticeDetailAdapter);
		
		setListener();
		
		setTitleNavBar();
	}
	
	@Override
	protected void setListener() {
		mListView.setOnScrollListener(new OnScrollListener() {
			
			@Override
			public void onScrollStateChanged(AbsListView arg0, int arg1) {
				
			}
			
			@Override
			public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
				if(arg1 >= 1){
					mNoticeDetailStatusView.setVisibility(View.VISIBLE);
				}else {
					mNoticeDetailStatusView.setVisibility(View.GONE);
				}
			}
		});
	}
	
	@Override
	protected void setTitleNavBar() {
		TitleNavBarView titleNavBarView = (TitleNavBarView)findViewById(R.id.titleNavBarView);
		titleNavBarView.setMessage(getString(R.string.notice_detail));
		titleNavBarView.setLeftButtonOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		titleNavBarView.setRightButtonVisibility(View.INVISIBLE);
	}
	
}
